import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      name:"郭旭升",
      age:18
  },
  getters: {
    get_name(state){
      return state.name
    },
    get_age(state){
      return state.age
    }
  },
  mutations: {
    //同步修改：修改数据的唯一方式
    mutation_age(state,payload){
      state.age += payload
    }
  },
  actions: {
    action_age({commit},payload){
      setTimeout(()=>{
        commit("mutation_age",payload)
      },1000)
    }
  },
  modules: {
  }
})
